package com.ruoyi.repast.controller;

import com.ruoyi.common.core.controller.BaseController;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;

import com.ruoyi.repast.entity.BPrivateRoom;
import com.ruoyi.repast.entity.BReserve;
import com.ruoyi.repast.service.BReserveService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangjialu
 * @date 2021/8/1 下午2:49
 */
@Controller
@RequestMapping("/repast/bReserve")
public class BReserveController extends BaseController {

    private String prefix = "repast/bReserve";


    @Autowired
    private BReserveService bReserveService;

    /**
     * 列表页面
     * @return
     */
    @GetMapping()
    public String list()
    {
        return prefix + "/bReserveList";
    }


    /**
     * 新增包间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/bReserveForm";
    }

    /**
     * 新增保存预约记录
     */
    @RequiresPermissions("monitor:job:add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated BReserve bReserve)
    {
        AjaxResult ajaxResult= bReserveService.saveBReserve(bReserve);
        return ajaxResult;
    }



    /**
     * 修改预约记录页面
     */
    @GetMapping("/edit/{bReserveId}")
    public String edit(@PathVariable("bReserveId") String bReserveId, ModelMap mmap)
    {
        mmap.put("bReserve", bReserveService.get(bReserveId));
        return prefix + "/bReserveEdit";
    }



    /**
     * 数据删除
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        bReserveService.deleteBReserveByIds(ids);
        return success();
    }


    /**
     * 分页数据查询
     * @param bReserve
     * @return
     */
    @PostMapping("/listPage")
    @ResponseBody
    public Object listPage(BReserve bReserve, Integer pageNum, Integer pageSize)
    {
        TableDataInfo list = bReserveService.listPage(bReserve,pageNum,pageSize);
        return list;
    }

}
